js
(() => {
let lastClickedItem = null;
function handleFileClick(event) {
if (!event.shiftKey) {
lastClickedItem = event.target.closest('li[data-type="navigation-file"]');
return;
}
const currentItem = event.target.closest('li[data-type="navigation-file"]');
if (!currentItem || !lastClickedItem) return;
const allFiles = Array.from(document.querySelectorAll('li[data-type="navigation-file"]'));
const startIndex = allFiles.indexOf(lastClickedItem);
const endIndex = allFiles.indexOf(currentItem);
if (startIndex === -1 || endIndex === -1) return;
const start = Math.min(startIndex, endIndex);
const end = Math.max(startIndex, endIndex);
allFiles.forEach(file => {
file.classList.remove('b3-list-item--focus');
});
for (let i = start; i <= end; i++) {
allFiles[i].classList.add('b3-list-item--focus');
}
event.preventDefault();
event.stopPropagation();
}
function initShiftSelect() {
document.removeEventListener('click', handleFileClick, true);
document.addEventListener('click', handleFileClick, true);
}
initShiftSelect();
window.initShiftSelect = initShiftSelect;
})();